package Test_1129;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 */
public class Solution {
    public static class TreeNode{
        public char val;//数据
        public TreeNode left;//左孩子
        public TreeNode right;//右孩子
        public TreeNode(char val) {
            this.val = val;
        }
    }
    public TreeNode createTree1(){
        //创建节点
        TreeNode A=new TreeNode('A');
        TreeNode B=new TreeNode('B');
        TreeNode C=new TreeNode('C');
        TreeNode D=new TreeNode('D');
        TreeNode E=new TreeNode('E');
        TreeNode F=new TreeNode('F');
        TreeNode G=new TreeNode('G');
        //连接节点
        A.left=B;
        A.right=C;
        B.left=D;
        B.right=E;
        C.left=F;
        C.right=G;
        return A;
    }

    //二叉树的遍历
    //先进行前序遍历，将元素放进去；
    //如果遇到#表示空
    public int i=0;
    public TreeNode createTree(String str){
          TreeNode root=null;
          if(str.charAt(i)!='#'){
              root=new TreeNode(str.charAt(i));
              i++;
              root.left=createTree(str);
              root.right=createTree(str);

          }else{
          i++;
    }
        return root;
    }

}
